'************************************************************************* '** DMM197.BAS ** '** This program retrieves values from the Keithlty 197 DMM. ** '************************************************************************* ON ERROR GOTO errtrap '************************************************************************* '** Open the COM port 1 and power up the 500-SERIAL. Wait for it to ** '** reset. Set Baud rate for 19200, no parity, 8 bits, and 2 stop ** '** bits. ** '************************************************************************* OPEN "COM1:19200,N,8,2,CS,DS,CD" FOR RANDOM AS #1 FOR I = 1 TO 1000: NEXT I 'Slight delay '************************************************************************* '** Send five carriage returns separated by a short delay to allow ** '** the 500-SERIAL to set it's baud rate. ** '************************************************************************* FOR I = 1 TO 5 PRINT #1, CHR$(13); : FOR T = 1 TO 500: NEXT T NEXT I '************************************************************************* '** Turn echo off to avoid reading echoed characters as readings. ** '************************************************************************* PRINT #1, "EC;0" 'EC = Echo, 0=off, 1=on FOR I = 1 TO 1000: NEXT I 'Wait for the receive 'buffer for COM port to fill A$ = INPUT$(LOC(1), #1) 'Now empty the input buffer 'of garbage and echoed 'characters. '************************************************************************* '** Send initialization commands to the 500-SERIAL and 556 ** '************************************************************************* CLS PRINT #1, "I": 'Send 'Init' command. PRINT #1, "RE;20" 'Send Remote Enable. PRINT #1, "OA;20;R0G0X" 'Send Auto Range, Readings 'with prefix data format. PRINT #1, "OA;20;U0X" 'Get 197 Status word. PRINT #1, "EN;20" 'Put 197 into talker mode. INPUT #1, STATUS$ 'Place status in STATUS$ LOCATE 1, 1: PRINT STATUS$ 'Print Status$ WHILE INKEY$ = "" PRINT #1, "OA;20;T4X" 'Continous on X PRINT #1, "EN;20" 'Retrieve a data point, place INPUT #1, volts$ 'data in variable 'volts$'. PRINT volts$ 'Print data WEND PRINT #1, "L;20" 'Put 197 back into Local Mode. CLOSE #1 'Close COM port. END errtrap: RESUME NEXT